package com.atguigu.flink.chapter11.hive;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.catalog.hive.HiveCatalog;

/**
 * @Author lzc
 * @Date 2022/11/1 11:24
 */
public class Flink01_Hive_1 {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 2000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);
        
        StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
    
        // 1. 创建 hiveCatalog
        HiveCatalog hive = new HiveCatalog("hive", "gmall", "input/");
        // 2. 注册
        tEnv.registerCatalog("hive", hive);
        tEnv.useCatalog("hive");
        tEnv.useDatabase("gmall");
        
        tEnv.sqlQuery("select" +
                          " * " +
                          "from abc")
            .execute()
            .print();
        
        // tEnv.executeSql("insert into ...")
        
    
    
    }
}
